home *** CD-ROM | disk | FTP | other *** search
- Path: centre.univ-orleans.fr!desiree!emmguyot
- From: emmguyot@desiree.univ-orleans.fr (Emmanuel GUYOT)
- Newsgroups: comp.lang.c
- Subject: Re: How to test a random generator ?
- Date: 31 Jan 1996 09:57:34 GMT
- Organization: CITU - Universite d'Orleans - FRANCE
- Message-ID: <4eneee$86r@centre.univ-orleans.fr>
- References: <4e2q7g$oe@centre.univ-orleans.fr> <4e933p$t25@longwood.cs.ucf.edu> <9603010.14743@mulga.cs.mu.OZ.AU>
- NNTP-Posting-Host: desiree.cnrs-orleans.fr
- X-Newsreader: TIN [version 1.2 PL2]
-
- Stephen Baillie (baillie@munta.cs.mu.OZ.AU) wrote:
-
- : There are various statistical tests you can use to determine if a
- : random number generator exhibits certain properties of truly
- : random sequences. The most common/appropriate/applicable is
- : probably the chi squared test. Basically, you take n random
- : numbers from the range a - b, then take the sum of the squares
- : of the differences between the actual occurances of each number
- : and the expected or average number, take the square root, and
- : the result should be roughly b-a. Too close to zero and it's
- : not random enough; too large and it shows too much bias towards
- : particular numbers. An example:
-
- : average = (double) iterations / (double) range;
- : for (chi2 = 0, i = 0; i < range; i++)
- : chi2 += (counts[i] - average) * (counts[i] - average);
-
- : /* Report the chi value, and a very rough assessment of the RNG */
- : printf("Chi value = %f ", sqrt(chi2));
- : if (sqrt(chi2) < range / 2)
- : printf("(not random enough)\n");
- : else if (sqrt(chi2) > range * 2)
- : printf("(too biased)\n");
- : else
- : printf("(not bad)\n");
-
-
- I'm a bit surprise by this because if you take a low number of iterations,
- I have the 'not bad' comment whereas if I use a high number of iterations
- I have the 'too biased' comment.
-
- Shouldn't the chi2 variable be average or something like that to take into
- account the number of iterations ?
-
- E.G.
-
- ------------------------------------------------------------------------------
- ---------------------------->>>> Emmanuel Guyot <<<<--------------------------
- LPCE-CNRS |
- 3A avenue de la Recherche Scientifique | Phone : 33 38 51 78 25
- 45071 Orleans Cedex 2 | Fax : 33 38 63 12 34
- France | EMail : emmguyot@cnrs-orleans.fr
- ------------------------------------------------------------------------------
- Home Page : http://desiree.cnrs-orleans.fr/cgi-bin/cpt_html?index
- ------------------------------------------------------------------------------
-